import 'package:dio/dio.dart';

/// 网络请求配置
class NetworkConfig {
  // 域名
  static String baseURL = "http://123.207.32.32:8001/";
  // 连接超时时间
  static const connectTimeOut = 10000;
  // 发送超时时间
  // static const sendTimeout = 10000;
  // 接收超时时间
  // static const receiveTimeout = 10000;
  // 请求成功状态码
  static const successCode = 200;
}

/// 网络请求响应模型
class NetworkResponseModel {
  int? code;
  String? message;

  NetworkResponseModel({this.code, this.message});

  factory NetworkResponseModel.fromJson(Map<String, dynamic> json) {
    NetworkResponseModel aModel = NetworkResponseModel();
    aModel.code = json['code'];
    aModel.message = json['message'];
    return aModel;
  }
}

/// 错误处理拦截器
class ErrorInterceptor extends Interceptor {
  @override
  void onError(DioError err, ErrorInterceptorHandler handler) {
    // error统一处理
    // ResponseException resException = ResponseException.fromDioError(err);
    // 错误提示
    // debugPrint('DioError===: ${resException.toString()}');
    // err.error = resException;
    super.onError(err, handler);
  }
}
